import request from '@/utils/request'

// 获取我的岗位列表
export function getMyPositions(params) {
  const { page = 0, size = 10, search = '' } = params || {}
  return request({
    url: '/api/teacher/jobs/positions',
    method: 'get',
    params: {
      page,
      size,
      search
    }
  })
}

// 创建岗位
export function createPosition(data) {
  return request({
    url: '/api/teacher/jobs/positions',
    method: 'post',
    data
  })
}

// 更新岗位
export function updatePosition(id, data) {
  return request({
    url: `/api/teacher/jobs/positions/${id}`,
    method: 'put',
    data
  })
}

// 删除岗位
export function deletePosition(id) {
  return request({
    url: `/api/teacher/jobs/positions/${id}`,
    method: 'delete'
  })
}

// 获取所有岗位分类
export function getCategories() {
  return request({
    url: '/api/common/job-categories',
    method: 'get',
    transformResponse: [(data) => {
      const parsed = JSON.parse(data)
      return Array.isArray(parsed) ? parsed : []
    }]
  })
} 